package Classes.GameViews.ViewDisplayers// ActionScript file
{
	import Classes.GameDatas.GD_MapGrid;
	import Classes.GameUtils.GU_IsoUtils;
	import Classes.GameViews.GV_Map;
	
	import flash.display.Graphics;
	import flash.geom.Point;

	public class VD_MapGrid extends ViewDisplayer
	{
		public function VD_MapGrid(gd:GD_MapGrid):void
		{
			super(gd);
			this.init();
		}
		
		private function init():void
		{
			var locationPoint:Point=GU_IsoUtils.isoToScreen(new Point(this.mapGridData.atx*GV_Map.instance.gridSize,this.mapGridData.aty*GV_Map.instance.gridSize));
			this.x=locationPoint.x;
			this.y=locationPoint.y;
		}
		
		private function fillColor(colorValue:uint):void
		{
			var graphics:Graphics=this.graphics;
			graphics.clear();
			graphics.lineStyle(0.1,0x000000);
			graphics.beginFill(colorValue,1);
			var gridSize:Number=GV_Map.instance.gridSize;
			graphics.moveTo(0,0);
			graphics.lineTo(-gridSize,gridSize/2);
			graphics.lineTo(0,gridSize);
			graphics.lineTo(gridSize,gridSize/2);
			graphics.lineTo(0,0);
			graphics.endFill();
		}
		
		public function fillByEnabled():void
		{
			if(this.mapGridData.buildEnabled)
			{
				this.fillColor(0x00ff00);
			}
			else
			{
			    this.fillColor(0xff0000);
			}
		}

		/*getter & setter*/	
		public function get mapGridData():GD_MapGrid
		{
			return this.gameData as GD_MapGrid;
		}

	}
}